<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class xbmc {

    public $os = NULL;

    public function __construct() {
        // not really a good detection, as it might be OSX or something else
        if (defined('PHP_WINDOWS_VERSION_MAJOR'))
            $this->os = "windows";
        else
            $this->os = "linux";
    }

    public function xbmc_update_library() {
        switch ($this->os) {
            case "windows":
                exec("xbmc-send -a \"UpdateLibrary(video)\" >> /dev/null 2>&1");
            case "linux":
                exec("xbmc-send -a \"UpdateLibrary(video)\" >> /dev/null 2>&1");
            default:
        }
    }

    public function xbmc_clean_library() {
        switch ($this->os) {
            case "windows":
                exec("xbmc-send -a \"CleanLibrary(video)\" >> /dev/null 2>&1");
            case "linux":
                exec("xbmc-send -a \"CleanLibrary(video)\" >> /dev/null 2>&1");
            default:
        }
    }

    public function xbmc_quit() {
        switch ($this->os) {
            case "windows":
                exec("xbmc-send -a \"Quit\" >> /dev/null 2>&1");
            case "linux":
                exec("xbmc-send -a \"Quit\" >> /dev/null 2>&1");
            default:
        }
    }

    public function xbmc_reboot() {
        switch ($this->os) {
            case "windows":
                exec("xbmc-send -a \"Reboot\" >> /dev/null 2>&1");
            case "linux":
                exec("xbmc-send -a \"Reboot\" >> /dev/null 2>&1");
            default:
        }
    }

    public function xbmc_notification($header, $message) {
        switch ($this->os) {
            case "windows":
                exec("xbmc-send -a \"Notification('{$header}','{$message}')\" >> /dev/null 2>&1");
            case "linux":
                exec("xbmc-send -a \"Notification('{$header}','{$message}')\" >> /dev/null 2>&1");
            default:
        }
    }

}

?>
